/**
 * Created by shbs on 06/06/2018.
 */
var Index={};
Index.init=function () {
    layui.use(['element'], function(){
        var element = layui.element;
        var $ = layui.$
        $(function(){
            $('.nav-item>a').on('click',function(){
                if (!$('.nav').hasClass('nav-mini')) {
                    if ($(this).next().css('display') == "none") {

                        $('.nav-item').children('ul').slideUp(300);
                        $(this).next('ul').slideDown(300);
                        $(this).parent('li').addClass('nav-show').siblings('li').removeClass('nav-show');
                    }else{

                        $(this).next('ul').slideUp(300);
                        $('.nav-item.nav-show').removeClass('nav-show');
                    }
                }
            });

            $('.mixbtn').on('click',function(){
                if (!$('.nav').hasClass('nav-mini')) {
                    $('.nav-item.nav-show').removeClass('nav-show');
                    $('.nav-item').children('ul').removeAttr('style');
                    $('.nav').addClass('nav-mini');
                    $('.layui-side-scroll').addClass('mini')
                    $('.layui-side').addClass('mini');
                    $('.layui-body').addClass('mini');
                    $('.mixbtn').children('i').removeClass('layui-icon-shrink-right').addClass("layui-icon-spread-left")
                }else{
                    $('.nav').removeClass('nav-mini');
                    $('.layui-side-scroll').removeClass('mini')
                    $('.layui-side-layui-bg-black').removeClass('mini');
                    $('.layui-body').removeClass('mini');
                    $('.mixbtn').children('i').removeClass('layui-icon-spread-left').addClass("layui-icon-shrink-right")
                }
            });
        });

    });
};

(function(){
    Index.init();
})()
